package com.quanyan.stadium.enums;

import com.quanyan.stadium.constants.GameConstants;

/**
 * Created by xiaoxiao on 16/6/2.
 *
 * 赛程积分枚举类, 足篮网羽
 */
public enum GameScheduleScoreEnum {

    GAME_SCHEDULE_SCORE_BIG_WIN(1,"1","足球胜利得分",3.0),
    GAME_SCHEDULE_SCORE_BIG_TIE(2,"1","足球平得分",1.0),
    GAME_SCHEDULE_SCORE_BIG_LOSE(3,"1","足球失败得分",0.0),
    GAME_SCHEDULE_SCORE_SMALL_WIN(4,"1","篮球,羽毛球,网球胜利得分",1.0),
    GAME_SCHEDULE_SCORE_SMALL_LOSE(5,"1","篮球,羽毛球,网球失败得分",0.0);

    public static Double getScore(int categoryId, Byte isWinTemp, Byte isHost){
        Double score = 0.0;
        Byte isWin = isWinTemp;
        if (isHost == GameConstants.IS_DELETE && isWinTemp.intValue() != GameConstants.SCHEDULE_TIE.intValue()) {    //客场的话胜负关系反转
            isWin = (byte)(1-isWinTemp);
        }
        if (categoryId == GameConstants.CATEGORY_ID_FOOTBALL) {
            if (isWin.intValue() == GameConstants.SCHEDULE_WIN.intValue()) {
                score = GAME_SCHEDULE_SCORE_BIG_WIN.getLabel();
            }else if (isWin.intValue() == GameConstants.SCHEDULE_LOSE.intValue()) {
                score = GAME_SCHEDULE_SCORE_BIG_LOSE.getLabel();
            }else {
                score = GAME_SCHEDULE_SCORE_BIG_TIE.getLabel();
            }
        }else if (categoryId == GameConstants.CATEGORY_ID_BADMINTON ||
                categoryId == GameConstants.CATEGORY_ID_BASKETBALL || categoryId == GameConstants.CATEGORY_ID_TENNIS) {
            if (isWin.intValue() == GameConstants.SCHEDULE_WIN.intValue()) {
                score = GAME_SCHEDULE_SCORE_SMALL_WIN.getLabel();
            }else{
                score = GAME_SCHEDULE_SCORE_SMALL_LOSE.getLabel();
            }
        }
        return score;
    }

    GameScheduleScoreEnum(int id, String code, String name, Double label) {
        this.id = id;
        this.code = code;
        this.name = name;
        this.label = label;
    }

    private int id;

    private String code;

    private String name;

    private Double label;

    public Integer getId() {
        return id;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public Double getLabel() {
        return label;
    }
}
